package sz.szsmk.citizencard.ui.activity;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;

import com.chenenyu.router.annotation.Route;

import sz.szsmk.citizencard.DaggerApplication;
import sz.szsmk.citizencard.R;
import sz.szsmk.citizencard.databinding.BusSearchSiteActivityBinding;
import sz.szsmk.citizencard.ioc.Compontent.DaggerCommonActivityComponent;
import sz.szsmk.citizencard.model.network.bean.response.QueryNearStandbyRes;
import sz.szsmk.citizencard.mvp.contract.IBusSiteSearchContact;
import sz.szsmk.citizencard.mvp.presenter.BusSiteSearchPresenter;
import sz.szsmk.citizencard.ui.adapter.BusSiteNearbyAdapter;
import sz.szsmk.citizencard.ui.base.IBaseActivity;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/12/17 17:57
 * description:站点搜索
 */
@Route("BusSearchSiteActivity")
public class BusSearchSiteActivity extends IBaseActivity<BusSiteSearchPresenter, BusSearchSiteActivityBinding>
        implements IBusSiteSearchContact.IBusSiteSearchView {

    private RecyclerView busSiteSearchRv;
    private BusSiteNearbyAdapter busSiteNearbyAdapter;

    @Override
    protected int attachLayoutRes() {
        return R.layout.bus_search_site_activity;
    }

    @Override
    protected void initInjector() {

        DaggerCommonActivityComponent.builder()
                .appCompontent(DaggerApplication.getAppComponent())
                .build().inject(this);
    }

    @Override
    protected void initViews() {
        mPresenter.getSearchList("string","string");
        busSiteSearchRv = dataBinding.busSiteSearchRv;
        dataBinding.titleLayout.back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
        busSiteSearchRv.setLayoutManager(linearLayoutManager);
        busSiteNearbyAdapter = new BusSiteNearbyAdapter(this);
        busSiteSearchRv.setAdapter(busSiteNearbyAdapter);
    }

    @Override
    protected void updateViews() {

    }

    @Override
    public void getSearchListSucc(QueryNearStandbyRes response) {
        busSiteNearbyAdapter.setViewData(response.getBusSiteList());
        busSiteNearbyAdapter.notifyDataSetChanged();
    }

    @Override
    public void getSearchListFail() {

    }
}
